import { makeAutoObservable } from 'mobx'
import { makePersistable } from 'mobx-persist-store'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { ResLogin } from '@/types/login'

class UserStore {
  constructor() {
    makeAutoObservable(this)
    makePersistable(this, {
      name: 'UserStore',
      properties: ['userInfo'],
      storage: AsyncStorage
    })
  }
  // 用户信息
  userInfo = {} as ResLogin
  // 存储用户信息
  saveUserInfo = (data: ResLogin) => {
    this.userInfo = data
  }
}

export const userStore = new UserStore()
